﻿using EDMDesigner.Business.Util;

namespace EDMDesigner.Business.SSDL
{
    public class SSDLContainer
    {
        public string Namespace { get; set; }
        public string Name { get; set; }
        public string Provider { get; set; }
        public string ProviderManifestToken { get; set; }

        private EventedObservableCollection<EntityType.EntityType> _entityTypes;
        public EventedObservableCollection<EntityType.EntityType> EntityTypes
        {
            get
            {
                if (_entityTypes == null)
                {
                    _entityTypes = new EventedObservableCollection<EntityType.EntityType>();
                    _entityTypes.ItemAdded += entityType => entityType.Container = this;
                }
                return _entityTypes;
            }
        }

        private EventedObservableCollection<Association.Association> _associationSets;
        public EventedObservableCollection<Association.Association> AssociationSets
        {
            get
            {
                if (_associationSets == null)
                {
                    _associationSets = new EventedObservableCollection<Association.Association>();
                    _associationSets.ItemAdded += association => association.Container = this;
                }
                return _associationSets;
            }
        }

        private EventedObservableCollection<Function.Function> _functions;
        public EventedObservableCollection<Function.Function> Functions
        {
            get
            {
                if (_functions == null)
                {
                    _functions = new EventedObservableCollection<Function.Function>();
                }
                return _functions;
            }
        }
    }
}
